package zhuyun.code.datamanager

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*
import java.lang.Exception
import java.sql.Connection
import java.sql.DriverManager

/**
 * Instrumented test, which will execute on an Android device.
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
    @Test
    fun useAppContext() {
        // Context of the app under test.
        val appContext = InstrumentationRegistry.getInstrumentation().targetContext
        assertEquals("zhuyun.code.datamanager", appContext.packageName)
    }

    val URL="jdbc:mysql://rdsz4kl5za13u8d0m3i8spublic.mysql.rds.aliyuncs.com:3306/chnspec?useUnicode=true&characterEncoding=UTF-8"
    val USER = "spec3205722251"
    val PASSWORD = "spec3205722251"
    val DRIVER_NAME = "com.mysql.jdbc.Driver"
    @Test
    fun connectMySql() {
        Class.forName(DRIVER_NAME)
        object :Thread(){
            override fun run() {
                var conn: Connection? = null
                try {
                    conn = DriverManager.getConnection(URL, USER, PASSWORD)
                } catch (e:Exception) {
                    e.printStackTrace()
                } finally {
                    conn?.close()
                }

            }

        }.start()


    }
}
